package com.cloud.logger.zchain.spring.config;

import com.cloud.logger.zchain.core.zookeeper.DefaultConnectionStateListener;
import com.cloud.logger.zchain.core.zookeeper.ZookeeperFactory;
import com.cloud.logger.zchain.spring.properties.ZchainProperties;
import com.cloud.logger.zchain.support.ScheduleAnnotaion;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.DependsOn;
import org.springframework.core.annotation.Order;

@Configuration
@Order(3)
public class SchedulingConfig {

    @Autowired
    private ZchainProperties zchainProperties;
    @Bean
    public ZookeeperFactory zookeeperFactory() throws Exception {
        ZookeeperFactory zookeeperFactory = ZookeeperFactory.getInstance();
        zookeeperFactory.init(zchainProperties.getZookeeper().getHost(), zchainProperties.getZookeeper().getNameSpace(),zchainProperties.getZookeeper().getConnectionTimeOut());
        return zookeeperFactory;
    }

    @Bean
    public DefaultConnectionStateListener defaultConnectionStateListener(){
       return new DefaultConnectionStateListener();
    }

    @Bean
    public ScheduleAnnotaion scheduleAnnotaion(){
        return new ScheduleAnnotaion();
    }

}
